package com.springsecurity.demo.jwt;

import io.jsonwebtoken.security.Keys;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.crypto.SecretKey;

/**
 * DESC:
 *
 * @author : yj
 * @since : 2020-08-24
 */

@Configuration
public class SecureKeyConfig {

    private final JwtConfig jwtConfig;
    @Autowired
    public SecureKeyConfig(JwtConfig jwtConfig) {
        this.jwtConfig = jwtConfig;
    }

    @Bean
    public SecretKey secretKey() {
        return Keys.hmacShaKeyFor(jwtConfig.getSecureKey().getBytes());
    }
}
